#include<bits/stdc++.h>
using namespace std;
int n,l,r,ans;
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	cin>>n>>l>>r;
	for(int i=l;i<=r;i++)
	{
		if(i > l+n)
			break;
		ans=max(ans,i%n);
	}
		
	cout<<ans;
	return 0;
}
